The present invention relates to a data processing system, and specifically to a method and apparatus for debug handling in a data processing system.
It is important to provide a useful and cost effective approach for allowing emulation and debug of a data processing system, particularly when the data processing system is implemented on an integrated circuit with limited pins or terminals to communicate information. Most emulation and debug approaches provide a mechanism to allow observability and controllability of portions of circuitry within the data processing system. For example, it is desirable to sample registers, memory, and on-chip peripherals at a given instruction boundary. Many processors perform scanning using a dedicated hardware interface.
To enter a debug session, an instruction and/or data may be marked. The debug session is then entered when the operation is terminated. The debug session allows the user to debug the programming code running on the system by evaluating the state of the machine at the point where the instruction and/or data is marked. This includes examining registers, memory, peripherals, etc. Upon completion of the debug session, execution continues after the last successfully completed instruction. It is desirable to sample the processor""s resources after the unsuccessful completion of an instruction, but prior to overwriting the values stored in these resources, such as often occurs on exception handling.
In a pipelined processor architecture, operations are divided into stages, where multiple instructions are moving through the pipeline, with one instruction per each stage. For example, a pipeline often includes the stages: fetch, decode, execute, and writeback. The program counter and instruction register stay ahead of the instruction that is currently in the execution stage, creating a problem on return from debug mode.
Where an exception occurs, the exception handling may overwrite the processor status and return address. For an imprecise machine, the exception results in a non-recoverable state of the processor. One prior art processor allows non-maskable breakpoints that allow the processor to stop, but incur a penalty that it may not be restartable.
A need therefore exists for a method of determining a last unsuccessful instruction which is reexecuted after debug. Similarly, a need exists for a method of debug handling that retains sufficient uncorrupted information to allow return to normal processing.